package com.example.admin.goodnews.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.entity.DailySalesDataEntity;

/**
 * 单日票房适配器
 * Created by admin on 2016/10/13.
 */

public class DailySalesAdapter extends RecyclerView.Adapter<DailySalesAdapter.ViewHolder> {
    private Context context;
    private DailySalesDataEntity dailySalesDataEntity;

    public DailySalesAdapter(Context context, DailySalesDataEntity dailySalesDataEntity) {
        this.context = context;
        this.dailySalesDataEntity = dailySalesDataEntity;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_dailysales, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv_moviename_dailysales.setText("电影名：" + dailySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getMovieName());
        holder.tv_boxoffice_dailysales.setText("单日票房：" + dailySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getBoxOffice());
        holder.tv_movieday_dailysales.setText("上映天数：" + dailySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getMovieDay());
        holder.tv_sumboxoffice_dailysales.setText("票房：" + dailySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getSumBoxOffice());
        holder.tv_avgpeople_dailysales.setText("场均人次：" + dailySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getAvpPeoPle());
    }

    @Override
    public int getItemCount() {
        return dailySalesDataEntity.getShowapi_res_body().getDatalist().size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_moviename_dailysales;// 电影名
        private TextView tv_boxoffice_dailysales;// 单日票房
        private TextView tv_movieday_dailysales;// 上映了几天
        private TextView tv_sumboxoffice_dailysales;// 票房
        private TextView tv_avgpeople_dailysales;// 场均人数


        public ViewHolder(View itemView) {
            super(itemView);
            tv_moviename_dailysales = (TextView) itemView.findViewById(R.id.tv_moviename_dailysales);// 电影名
            tv_boxoffice_dailysales = (TextView) itemView.findViewById(R.id.tv_boxoffice_dailysales);// 单日票房
            tv_movieday_dailysales = (TextView) itemView.findViewById(R.id.tv_movieday_dailysales);// 上映了几天
            tv_sumboxoffice_dailysales = (TextView) itemView.findViewById(R.id.tv_sumboxoffice_dailysales);// 票房
            tv_avgpeople_dailysales = (TextView) itemView.findViewById(R.id.tv_avgpeople_dailysales);// 场均人数
        }
    }
}
